package com.hui.auth.exception;

/**
 * 自定义异常
 *
 * @author LiaoYunHui 2017/9/29/029.
 */
public class CustomException extends RuntimeException {

    private static final long serialVersionUID = 5536093022350862167L;

    private AuthError authError;

    public CustomException(AuthError authError) {
        super(authError.msg);
        this.authError = authError;
    }

    public AuthError getAuthError() {
        return authError;
    }

    public static void err(AuthError authError) {
        throw new CustomException(authError);
    }

    public static void err(String msg) {
        throw new CustomException(AuthError.make(-1, msg));
    }

    public static void err(int code, String msg) {
        throw new CustomException(AuthError.make(code, msg));
    }
}
